//
//  KKBuyersEditTableViewCell.m
//  FreightAssistant
//
//  Created by leo on 15/11/6.
//  Copyright © 2015年 leo. All rights reserved.
//

#import "KKEditTableViewCell.h"

@interface KKEditTableViewCell() {
    
    NSString *_editKey;
}

@end

@implementation KKEditTableViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSettingInfo:(NSDictionary*)settings andWithValueInfo:(NSDictionary*)valueInfo {
    
    _editKey = settings[@"key"];
    NSString *title = settings[@"title"];
    NSString *placeholder = settings[@"placeholder"];
    NSString *value = valueInfo[_editKey];
    
    _kk_titleLabel.text = title;
    _kk_valueTextField.placeholder = placeholder;
    _kk_valueTextField.text = value;
}


#pragma mark - UITextField methods

- (BOOL)textFieldShouldEndEditing:(UITextField *)textField {
    
    if (_editHandle) {
        _editHandle(textField.text, _editKey);
    }
    
    return true;
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    
    [textField resignFirstResponder];
    return true;
}

@end
